import { createRouter, createWebHistory } from 'vue-router'
const routes = [

  {
    path: '/login',
    name: 'login',

    component: () => import("@/views/Login.vue")
  },

  {
    path: '/main',
    component: () => import("@/views/Main.vue"),
    name: "main"

  },
  {
    path: '/',
    redirect: '/login'
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes
})
router.beforeEach((to, from) => {
  if (to.path != "/login" && !sessionStorage.getItem("login")) {
    return "/login"
  }
})
export default router
